<!DOCTYPE >
<html>
<head>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<title>基本设置</title>
<css  href="__PUBLIC__/system/css/right.css" />
<js href="__PUBLIC__/system/js/jquery.js" />
<js href="__PUBLIC__/system/js/system.js" />
<js href="__PUBLIC__/system/js/admin.js" />
<script type="text/javascript" src="__PUBLIC__/ueditor/ueditor.config.js"></script>
<script type="text/javascript" src="__PUBLIC__/ueditor/ueditor.all.js"></script>
<js href="__PUBLIC__/system/js/ajaxupload.js" />
</head>
<body style="overflow: auto;">

	<div class="basic bor">
			<div class="title fl">当前位置：图片管理 > 添加图片</div>
			<div class="basic_r fr"><a href="{:U('Index/setting')}">基本信息</a></div>
	</div>
<div class="notice">
	<div class="n_title">
		<span class="fl">添加图片</span> 
	</div>
	<div class="ncontent">
		<form action="{:U('Product/cateadd')}" method="post" enctype="multipart/form-data" >
			<div class="setting"> 
				<ul>
					<li>
						<dd class="setting_t fl"><span>*</span>图片标题 ：</dd>
						<dd class="setting_p fl"><input class="seinp" type="text" name="name" value="{$catename.name}">
							<span>图片名称不能为空</span>
						</dd>
					</li>


					<li>
						<dd class="setting_t fl"><span>*</span>推荐 ：</dd>
						<dd class="setting_p fl">
						<label><input name="fruit" type="radio" <if condition="$catename['fruit'] eq 1 ">checked = "checked"</if> value="1"/>
						</label> 是
						<label><input name="fruit" type="radio" <if condition="$catename['fruit'] eq 0 ">checked = "checked"</if>value="0" /> 
						</label> 否 
						</dd>
					</li>

					<li>
						<dd class="setting_t fl"><span>*</span>电脑主图 ：</dd>
						<dd class="setting_p fl">
							<div class="infx">
							<input class="infile" type="file" id="J_dy_img1" >
							
							<span class="text_s">PC主图</span>
							</div>
								<span><img src="{$catename.pic}"  id="is_lodding1" height="80" alt=""></span>
							</dd>
							&nbsp;
							&nbsp;
					</li>
					<li>
						<dd class="setting_t fl"><span>*</span>手机主图 ：</dd>
						<dd class="setting_p fl">
							<div class="infx">
							<input class="infile" type="file" id="J_dy_img2" name="mpic">
							<span class="text_s">手机主图</span>
							</div>
							<span>请按照当前尺寸及大小修改！</span>
							
							</dd>
							&nbsp;
							&nbsp;
							<span><img src="{$catename.mpic}" id="is_lodding2" height="100"></span>
					</li>



					<li>
						<dd class="setting_t fl"><span>*</span>细节图 ：</dd>
						<dd class="setting_p fl colorfont">
								<div class="infx">
							<input class="infile" type="file" id="J_dy_img3" name="mpic">
							<span class="text_s">细节图</span>
							</div>
							<div id="minpic">

								<volist name="catename.iocs" id="vo">

								<a class="liLabel" title="点击图片即可删除对应的细节图片"><img src="{$vo}" height="50px;" style="margin-left:10px;"> <input class="infile" name="ioc[]" type="text" value="{$vo}"></a>

								</volist>

						</div>
							</dd>
						
					</li>

		
						

					<li>
						<dd class="setting_t fl">关键词 ：</dd>
						<dd class="setting_p fl"><input class="seinp" type="text" name="keyword" value="{$catename.keyword}">
							<span>请用逗号隔开（如：关键词，关键词，关键词）</span>
						</dd>
					</li>
						


					<li>
						<dd class="setting_t fl">图片摘要 ：</dd>
						<dd class="setting_p fl"><textarea name="description" class="textarea bor" >{$catename.description}</textarea></dd>
					</li>

					

					<li>
						<dd class="setting_t fl"><span>*</span> 图片类别 ：</dd>
						<dd class="setting_p fl">
							<select  name="uid" id="uid" >
								<volist name="cate" id="ov">
								<option value="{$ov.id}" <if condition="$ov[id] eq $catename[uid] ">selected = "selected"</if>  >{$ov.html}{$ov.name}</option>
								</volist>
							</select>

						</dd>
					</li>
						<li>
							<dd class="setting_t fl">图片内容 ：</dd>
							<dd class="setting_p intop fl">
								<textarea name="content" class="textarea textared" id ='container'> {$catename.content}</textarea>
							</dd>
						</li>
						<li>
							<dd class="setting_t fl"> &nbsp;</dd>
							<dd class="setting_p fl">
							<input  type="hidden" name="id" value="{$catename.id}">
							<input  type="hidden" name="case_uid"  value="{$_GET[case_id]}">
							<input  type="hidden" name="pic" id="is_pach1" value="{$catename.pic}">
							<input  type="hidden" name="mpic" id="is_pach2" value="{$catename.mpic}">
							<input class="submit" type="submit" name="" value="保存">
							</dd>
						</li>
					</ul>
						

			</div>
		</form>
	 </div>
	</div>

  <script type="text/javascript">
  $(function(){

  });
// 上传细节图
  var ue = UE.getEditor('container', {
    initialFrameWidth:800,
    initialFrameHeight:300
  
  });
    </script>
      <script>
  //异步上传图片
    //上传图片 
    
   var oBtn1 = document.getElementById("J_dy_img1"); 
	var oBtn2 = document.getElementById("J_dy_img2"); 
	var oBtn3 = document.getElementById("J_dy_img3"); 
    new AjaxUpload(oBtn1,{
        action : "{:U('Index/AjaxUpload_Layout')}",
        data:{name:'pic',pach:'product'},
        onSubmit:function(file,ext){
            if(ext && /^(jpg|jpeg|png)$/.test(ext)){
                //ext是后缀名
                
                oBtn1.disabled = "disabled";
            }else{  ;
                return false;
            }
        }, 
        onComplete:function(file,response){ 
            var res = JSON.parse(response);
            if(res.status == 1){ 
            	$('#is_lodding1').show();
          	  $('#is_pach1').val('');//格式化路径
              $('#is_lodding1').attr('src','');//格式化路径
              $('#is_lodding1').attr('src',res.path);
              $('#is_pach1').val(res.path);
              oBtn1.disabled = false;
             }else{
                alert('上传图片过大，请重新上传');
                oBtn1.disabled = false;
          }
        }
    });

       
    new AjaxUpload(oBtn2,{
        action : "{:U('Index/AjaxUpload_Layout')}",
        data:{name:'pic',pach:'mproduct'},
        onSubmit:function(file,ext){
            if(ext && /^(jpg|jpeg|png)$/.test(ext)){
                //ext是后缀名
                oBtn2.disabled = "disabled";
            }else{  ;
                return false;
            }
        }, 
        onComplete:function(file,response){ 
            var res = JSON.parse(response);
            if(res.status == 1){ 
            	 $('#is_lodding2').show();
          	  $('#is_pach2').val('');//格式化路径
              $('#is_lodding2').attr('src','');//格式化路径
              $('#is_lodding2').attr('src',res.path);
              $('#is_pach2').val(res.path);
              oBtn2.disabled = false;
             }else{
                alert('上传图片过大，请重新上传');
                oBtn2.disabled = false;
          }
        }
    });
    new AjaxUpload(oBtn3,{
        action : "{:U('Index/AjaxUpload_Layout')}",
        data:{name:'pic',pach:'drawing'},
        onSubmit:function(file,ext){
            if(ext && /^(jpg|jpeg|png)$/.test(ext)){
                //ext是后缀名
             
                oBtn3.disabled = "disabled";
            }else{  ;
                return false;
            }
        }, 
        onComplete:function(file,response){ 
            var res = JSON.parse(response);
            if(res.status == 1){ 
            	html = "<a  class='liLabel' title='点击图片即可删除对应的细节图片'><img src='"+res.path+"'  height='50px;' style='margin-left:10px;'> <input class='infile' name='ioc[]' type='text' value='"+res.path+"' ></a>";
            	$('#minpic').prepend(html);
              oBtn3.disabled = false;
             }else{
                alert('上传图片过大，请重新上传');
                oBtn3.disabled = false;
          }
        }
    });

   
  $(function(){

  			path = $('#is_lodding1').attr('src');
  			path1 = $('#is_lodding2').attr('src');
  			if (path == '') {
  				$('#is_lodding1').hide();
  			}if (path1 == '') {
  				$('#is_lodding2').hide();
  			}
			 //删除细节图
  			
			$("body").on('click','.liLabel',function(){
				$(this).remove();
			});

  })
   

</script> 

</body>
</html>